package org.uim.cricket.afetcher;

import java.io.FileReader;
import java.io.FileWriter;
import java.util.Properties;

public class FetcherProperties {

public static String FETCHER_CONFIG_FILE = "../config/analyzer-executor.properties";
	
	private Properties prop = null;
	
	public void load() {
		prop = new Properties();
		try {
			prop.load(new FileReader(FETCHER_CONFIG_FILE));
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
	public String getProperty(String key) {
		if (prop == null) return null;
		return prop.getProperty(key);
	}
	
	public void setProperty(String key, String val) {
		if (prop == null) return;
		prop.setProperty(key, val);
	}
	
	public Properties getProp() {
		return prop;
	}
	
	public void write() {
		try {
			if (prop != null) {
				prop.store(new FileWriter(FETCHER_CONFIG_FILE), null);
			}
		} catch (Exception ex) {
			AFlogger.error(" Failed to write properties!");
		}
	}
	
}
